// 1. 数字枚举
enum Color { Red = 1, Green, Blue = '4' }

// 正向映射： key -> value
let c1: Color = Color.Green;
let c2: Color = Color.Blue
console.log('c1:', c1, 'c2:', c2); // c1: 2 c2: '4'

// 反向映射： value -> key
let c1Name: string = Color[1]
let c2Name: string = Color[Color.Green]
console.log('c1Name:', c1Name); // Red
console.log('c2Name:', c2Name); // Green

// 2. 字符串枚举
enum bgc { skyblue = 'sb', rosered = 'rr', highgray = 'hg', grassgreen = 'gg' }
let bgc1 = bgc.skyblue
console.log('bgc1', bgc1); // 'sb'

// 3. 枚举可扩展，同样叫bgc
enum bgc {
  DarkRed = 3,
  DarkGreen,
  DarkBlue
}
let bgc2 = bgc.DarkRed
console.log('bgc2', bgc2); // bgc2 3

// 4. 常量枚举
const enum state {
  success = 1,
  error = 2,
}
let state1: state = state.success
console.log(state1);
